function removeDuplicates(nums: number[]): number {
    let prev = 0;
    for (let i = 1; i < nums.length; ++i) {
        if (nums[i] !== nums[prev]) {
            nums[++prev] = nums[i];
        }
    }
    return prev + 1;
};
